package com.sunday.common.mybatis.business.annotation.mock;


import com.sunday.common.mybatis.business.annotation.core.DataMapping;
import com.sunday.common.mybatis.business.annotation.core.DataStrongCheck;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Slf4j
@Component
public class BusinessService implements DataStrongCheck<Query> {

    @Override
    public List<DataMapping> getRealTimeData(Query query) {
        log.info("入参输出 : {}", query);
        return Optional.ofNullable(query)
                .map(dm -> Stream.iterate(0, i -> i < 10, i -> i + 1)
                        .map(i -> DataMapping.of(i + "label", i + "name"))
                        .collect(Collectors.toList()))
                .orElseGet(List::of);
    }
}
